import json

import pytest
import requests
import api.test2.Utils as Utils


class Method:
    def login(self, session, data):
        url = "http://localhost:90/login/verifyLogin"
        session.get(url, parmas=data)

    def send_get(self, session, url, data):
        response = session.get(url, params=data)
        response.encoding = "utf-8"
        code = response.status_code
        txt = response.text
        result = json.loads(txt)
        return {"code": code, "result": result}

    def send_post(self, session, url, data):
        response = session.post(url, data=data)
        response.encoding = "utf-8"
        code = response.status_code
        txt = response.text
        result = json.loads(txt)
        return {"code": code, "result": result}

    def send_delete(self, session, url, data):
        response = session.delete(url, params=data)
        response.encoding = "utf-8"
        code = response.status_code
        txt = response.text
        result = json.loads(txt)
        return {"code": code, "result": result}

    def send_put(self, session, url, data):
        response = session.put(url,  params=data)
        response.encoding = "utf-8"
        code = response.status_code
        txt = response.text
        result = json.loads(txt)
        return {"code": code, "result": result}
